HAL SPDIFRX types migration

This section provides information about the HAL SPDIFRX types migration.

HAL SPDIFRX state type definition

In HAL2, SPDIFRX is managed through three distinct state machines:

  • Global state machine: hal_spdifrx_state_t

  • Data state machine: hal_spdifrx_data_state_t

  • Control state machine: hal_spdifrx_control_state_t

HAL1

HAL2

typedef enum
{
 HAL_SPDIFRX_STATE_RESET,
 HAL_SPDIFRX_STATE_READY,
 HAL_SPDIFRX_STATE_BUSY,
 HAL_SPDIFRX_STATE_BUSY_CX,
 HAL_SPDIFRX_STATE_BUSY_RX,
 HAL_SPDIFRX_STATE_ERROR
} HAL_SPDIFRX_StateTypeDef
typedef enum
{
  HAL_SPDIFRX_STATE_RESET,
  HAL_SPDIFRX_STATE_INIT,
  HAL_SPDIFRX_STATE_CONFIGURED
} hal_spdifrx_state_t

typedef enum
{
  HAL_SPDIFRX_STATE_DATA_RESET,
  HAL_SPDIFRX_STATE_DATA_IDLE,
  HAL_SPDIFRX_STATE_DATA_ACTIVE,
  HAL_SPDIFRX_STATE_DATA_ABORT
} hal_spdifrx_data_state_t

typedef enum
{
  HAL_SPDIFRX_STATE_CONTROL_RESET,
  HAL_SPDIFRX_STATE_CONTROL_IDLE,
  HAL_SPDIFRX_STATE_CONTROL_ACTIVE,
  HAL_SPDIFRX_STATE_CONTROL_ABORT
} hal_spdifrx_control_state_t

Related concept: Revised and optimized HAL state machine


HAL SPDIFRX callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_SPDIFRX_CX_CPLT_CB_ID,
  HAL_SPDIFRX_CX_HALF_CB_ID,
  HAL_SPDIFRX_ERROR_CB_ID,
  HAL_SPDIFRX_MSPDEINIT_CB_ID,
  HAL_SPDIFRX_MSPINIT_CB_ID,
  HAL_SPDIFRX_RX_CPLT_CB_ID,
  HAL_SPDIFRX_RX_HALF_CB_ID
} HAL_SPDIFRX_CallbackIDTypeDef
  • Removed from HAL2 : the callback registration is managed by dedicated functions for each SPDIFRX event. For more details, see : HAL SPDIFRX register callback and HAL SPDIFRX unregister callback.

  • HAL_SPDIFRX_MSPINIT_CB_ID and HAL_SPDIFRX_MSPDEINIT_CB_ID are removed because the functions HAL_SPDIFRX_MspInit() and HAL_SPDIFRX_MspDeInit() are removed.

Related concepts:


HAL SPDIFRX initialization type definition

HAL1

HAL2

In HAL1, the configuration parameters such as Retries, WaitForActivity, ChannelSelection, StereoMode, PreambleTypeMask, ChannelStatusMask, ValidityBitMask, ParityErrorMask, SymbolClockGen, BackupSymbolClockGen are members of the SPDIFRX_InitTypeDef structure.

In HAL2, these parameters have been removed from hal_spdifrx_config_t. As they are optional, they are now managed by unitary functions in HAL SPDIFRX driver.

typedef struct
{
  uint32_t InputSelection
  uint32_t DataFormat


  uint32_t Retries


  uint32_t WaitForActivity


  uint32_t ChannelSelection


  uint32_t StereoMode



  uint32_t PreambleTypeMask
  uint32_t ChannelStatusMask
  uint32_t ValidityBitMask
  uint32_t ParityErrorMask

  FunctionalState SymbolClockGen
  FunctionalState BackupSymbolClockGen

} SPDIFRX_InitTypeDef
typedef struct
{
  hal_spdifrx_input_selection_t input_selection
  hal_spdifrx_data_format_t     data_format
} hal_spdifrx_config_t

HAL_SPDIFRX_SetSynchroRetries(hal_spdifrx_handle_t *hspdifrx,
                              hal_spdifrx_synchro_retries_t synchro_retries);

HAL_SPDIFRX_EnableWaitForActivity(hal_spdifrx_handle_t *hspdifrx);
HAL_SPDIFRX_DisableWaitForActivity(hal_spdifrx_handle_t *hspdifrx);

HAL_SPDIFRX_SetControlChannel(hal_spdifrx_handle_t *hspdifrx,
                              hal_spdifrx_control_channel_t control_channel);

HAL_SPDIFRX_EnableAlignmentForStereoOverrun(hal_spdifrx_handle_t *hspdifrx);
HAL_SPDIFRX_DisableAlignmentForStereoOverrun(hal_spdifrx_handle_t *hspdifrx);


HAL_SPDIFRX_SetMasks(hal_spdifrx_handle_t *hspdifrx,
                     const hal_spdifrx_masks_t *p_masks);



HAL_SPDIFRX_EnableSymbolClock(hal_spdifrx_handle_t *hspdifrx,
                              hal_spdifrx_backup_symbol_clock_status_t backup_symbol_clock_status);
HAL_SPDIFRX_DisableSymbolClock(hal_spdifrx_handle_t *hspdifrx);

HAL SPDIFRX handle type definition

HAL1

HAL2

SPDIFRX_HandleTypeDef
hal_spdifrx_handle_t

Related concept: Renaming of the handle structure


HAL SPDIFRX data format type definition

HAL1

HAL2

The SPDIFRX_SetDataFormatTypeDef structure is used in the HAL_SPDIFRX_SetDataFormat() function to change the data format, stereo mode, and masks after first initialization is done.

The user can configure the SPDIFRX data format within the HAL_SPDIFRX_SetConfig(). He can also change the stereo mode and masks using unitary functions in HAL SPDIFRX driver.

See also how to migrate the HAL_SPDIFRX_SetDataFormat() function to HAL2 code : Sets SPDIFRX data format.

typedef struct
{
  uint32_t DataFormat;


  uint32_t StereoMode;



  uint32_t PreambleTypeMask;
  uint32_t ChannelStatusMask;
  uint32_t ValidityBitMask;
  uint32_t ParityErrorMask;
} SPDIFRX_SetDataFormatTypeDef;
typedef struct
{
  hal_spdifrx_data_format_t data_format
} hal_spdifrx_config_t

HAL_SPDIFRX_EnableAlignmentForStereoOverrun(hal_spdifrx_handle_t *hspdifrx);
HAL_SPDIFRX_DisableAlignmentForStereoOverrun(hal_spdifrx_handle_t *hspdifrx);


HAL_SPDIFRX_SetMasks(hal_spdifrx_handle_t *hspdifrx, const hal_spdifrx_masks_t *p_masks);

HAL SPDIFRX callback type definition

HAL1

HAL2

typedef  void (*pSPDIFRX_CallbackTypeDef)(SPDIFRX_HandleTypeDef *hspdif)
typedef  void (*hal_spdifrx_cb_t)(hal_spdifrx_handle_t *hspdifrx)